package com.zjzywl.smoke.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zjzywl.smoke.authenticate.AuthUser;
import com.zjzywl.smoke.repository.YoyRepository;
import com.zjzywl.smoke.util.WebResult;
import com.zjzywl.smoke.entity.SysUser;

@RestController
@RequestMapping(value = "/bigData/yoy")
public class YoyController extends BaseController {
	@Autowired
	private YoyRepository yoyrepository;

	// 获取总报警数同比
	@RequestMapping(value = "/alarmValue")

	public WebResult getAlarmTypes() {
		AuthUser loginUser = this.getLoginUser();
		SysUser people = loginUser.getPeople();
		String disposePeople = people.getName();
		List alarmTypes = new ArrayList<>();
		alarmTypes.add(yoyrepository.findByType("一周总报警数同比" + disposePeople));
		alarmTypes.add(yoyrepository.findByType("一月总报警数同比" + disposePeople));
		alarmTypes.add(yoyrepository.findByType("一季度总报警数同比" + disposePeople));
		if (alarmTypes != null) {
			return WebResult.OK(alarmTypes);
		} else {
			return WebResult.FAIL("同比参数出错");
		}
	}

	// 获取高危场所同比
	@RequestMapping(value = "/hightAlarmValue")
	public WebResult getHighAlarmTypes() {
		List alarmTypes = new ArrayList<>();
		alarmTypes.add(yoyrepository.findByType("一周高危场所同比"));
		alarmTypes.add(yoyrepository.findByType("一月高危场所同比"));
		alarmTypes.add(yoyrepository.findByType("一季度高危场所同比"));
		if (alarmTypes != null) {
			return WebResult.OK(alarmTypes);
		} else {
			return WebResult.FAIL("同比参数出错");
		}
	}

	// 获取中危场所同比
	@RequestMapping(value = "/mediumAlarmValue")
	public WebResult getMediumAlarmTypes() {
		List alarmTypes = new ArrayList<>();
		alarmTypes.add(yoyrepository.findByType("一周中危场所同比"));
		alarmTypes.add(yoyrepository.findByType("一月中危场所同比"));
		alarmTypes.add(yoyrepository.findByType("一季度中危场所同比"));
		if (alarmTypes != null) {
			return WebResult.OK(alarmTypes);
		} else {
			return WebResult.FAIL("同比参数出错");
		}
	}

	// 获取未处理数同比
	@RequestMapping(value = "/NotDealValue")
	public WebResult getNotDeal() {
		List alarmTypes = new ArrayList<>();
		alarmTypes.add(yoyrepository.findByType("一周未处理数同比"));
		alarmTypes.add(yoyrepository.findByType("一月未处理数同比"));
		alarmTypes.add(yoyrepository.findByType("一季度未处理数同比"));
		if (alarmTypes != null) {
			return WebResult.OK(alarmTypes);
		} else {
			return WebResult.FAIL("同比参数出错");
		}
	}
}
